package user;

import book.BookList;
import operation.*;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: XMQ
 * Date: 2022-05-19
 * Time: 9:41
 */
public class User {
    protected String name;//管理员的用户名

    protected IOperation[] iOperations;//把所有操作都放到一个数组让管理员选择

    public User(String name) {
        this.name = name;
        iOperations = new IOperation[]{
                new ExitOperation(),//0下标
                new FindOperation(),
                new AddOperation(),
                new DelOperation(),
                new DisplayOpeartion()
        };
    }

    //管理员所接收的菜单
    public int menu(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("=======================");
        System.out.println("1.查找图书");
        System.out.println("2.新增图书");
        System.out.println("3.删除图书");
        System.out.println("4.显示图书");
        System.out.println("0.退出系统");
        System.out.println("请输入你的操作：");
        int choice = scanner.nextInt();
        return choice;

    }

    //通过管理员要进行的操作选择，来对书架进行对应的操作
    public void doOpeartion(int choice, BookList bookList){
        this.iOperations[choice].work(bookList);
    }
}
